package wuuxiang.crm;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

public class HydxyxAction {
	public WebDriver driver;

	public static void main(String[] args) {
		System.setProperty("webdriver.firefox.bin", "D:/Firefox.exe");
		WebDriver driver = new FirefoxDriver();
		driver.manage().window().maximize();
		Base loginShop = new Base(driver);
		loginShop.login("tcsl", "123456", "1001", "14235");

		// 发券
		HydxyxElement f = new HydxyxElement(driver);
		// 定位左边frame
		WebElement zbk1 = driver.findElement(By.name("leftFrame"));
		System.out.println(zbk1);
		driver.switchTo().frame(zbk1);
		// 点击营销处理
		ElectronicQuanElement q = new ElectronicQuanElement(driver);
		q.findyxcl();

		driver.manage().timeouts().implicitlyWait(11, TimeUnit.SECONDS);

		// 点击会员短信营销
		f.hydx();

		// 还原frame
		driver.switchTo().defaultContent();
		// 定位右边frame
		WebElement ybk2 = driver.findElement(By.name("mainFrame"));
		System.out.println(ybk2);
		driver.switchTo().frame(ybk2);

		WebElement ybk3 = driver.findElement(By.xpath("//*[contains(@src,'/shop/colligate/ConsumeWarnAction.a')]"));
		System.out.println(ybk3);
		driver.switchTo().frame(ybk3);

		driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);

		f.phone("18722405350");

		driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);

		// 刷新页面重新定位元素
		WebElement gouxuan = driver.findElement(By.xpath("//*[@id='doSendMsg']"));
		gouxuan.click();

		// ((JavascriptExecutor)driver).executeScript("document.getElementById('ticketKindId').value='丫蛋宝宝专用'");
	}
}
